package com.litchi.tutor.controller;


import com.litchi.tutor.common.base.ResponseVO;
import com.litchi.tutor.common.entity.Activity;
import com.litchi.tutor.service.ActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xyouzi
 * @since 2021-11-03
 */
@RestController
@Api("活动管理")
@RequestMapping("/activity")
public class ActivityController {

    @Autowired
    ActivityService activityService;

    @RequestMapping(value = "/dashboard/activity", method = RequestMethod.GET)
    @ApiOperation("查询活动")
    public ResponseVO getActivity() {
        List<Activity> list = activityService.list();
        return ResponseVO.ok(list);
    }

    @RequestMapping(value = "/dashboard/activity/{id}", method = RequestMethod.GET)
    @ApiOperation("根据id查活动")
    public ResponseVO getActivityById(@PathVariable Integer id) {
        Activity byId = activityService.getById(id);
        return ResponseVO.ok(byId);
    }


}

